﻿using System.Web.Mvc;
using Nop.Core;
using Nop.Services.Directory;
using Nop.Web.Framework.Security;
using Nop.Web.Models.Home;

namespace Nop.Web.Controllers
{
    public partial class HomeController : BaseNopController
    {
        private readonly IWorkContext _workContext;
        private readonly IRegionService _regionService;
        public HomeController(IWorkContext workContext, IRegionService regionService)
        { 
            this._workContext = workContext;
            this._regionService = regionService;
        }
        

        [NopHttpsRequirement(SslRequirement.No)]
        public ActionResult Index()
        {
            var model = new HomeModel();
            model.IsExpressAvailableRegion = IsExpressAvailableRegion();
            return View(model);
        }
        public bool IsExpressAvailableRegion()
        {
            var customer = _workContext.CurrentCustomer;
            var regions = _regionService.GetAllRegions();
            if (customer.Region != null && regions.Contains(customer.Region))
                return true;

            return false;
        }
    }
}
